home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
TCL1
/
GRAPH_FO
/
(GRAPH
/
CGRAPHTE
/
CGRAPHTA.C
< prev
next >
Wrap
Text File
|
1991-02-09
|
4KB
|
134 lines
/******************************************************************************
CGraphTask.c
The GraphTask Class
SUPERCLASS = CMouseTask.c
Copyright ⌐ 1991 Maarten Meijer. All rights reserved.
******************************************************************************/
#include <MacTypes.h>
#include <Global.h>
#include "CGraphTask.h"
/**** C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S ****/
/******************************************************************************
IGraphTask
The IGraphTask should setup enough information to UNDO later.
*******************************************************************************/
void
CGraphTask::IGraphTask(short aNameIndex, CPanorama *theRama, Graph *theGraph,
Point from) {
itsStart = from;
itsGraph = theGraph;
itsRama = theRama;
IMouseTask(aNameIndex);
notified = false; /* Notify only on succes !! */
}
/******************************************************************************
Notify
Notify its supervisor on succesful completion.
*******************************************************************************/
void
CGraphTask::Notify() {
if(!notified) {
notified = true;
itsRama->Notify(this);
}
}
/******************************************************************************
BeginTracking
*******************************************************************************/
void
CGraphTask::BeginTracking(Point *startPt) {
PenMode(patXor);
PenPat(gray);
Draw(itsStart, *startPt);
PenNormal();
}
/******************************************************************************
KeepTracking
*******************************************************************************/
void
CGraphTask::KeepTracking(Point *currPt, Point *prevPt, Point *startPt) {
RgnHandle clipRgn;
Rect r, f;
long curTicks;
Point start, new;
itsRama->GetPosition(&start);
clipRgn = NewRgn();
if( itsRama->AutoScroll(*currPt) || ! EqualPt(*currPt, *prevPt)) {
itsRama->GetPosition(&new);
GetClip(clipRgn);
r = (**clipRgn).rgnBBox;
OffsetRect(&r, start.h - new.h, start.v - new.v);
itsRama->GetFrame(&f);
PinInRect(&f, (Point *)&(r.top));
PinInRect(&f, (Point *)&(r.bottom));
ClipRect(&r); /* change clipping region to allow for scrolling */
/* that may have occured */
PenMode(patXor);
PenPat(gray);
Draw(itsStart, *prevPt);
SetClip(clipRgn);
Draw(itsStart, *currPt);
PenNormal();
}
DisposeRgn(clipRgn);
}
void
CGraphTask::EndTracking(Point *currPt, Point *prevPt, Point *startPt) {
PenMode(patXor);
PenPat(gray);
Draw(itsStart, *prevPt);
PenNormal();
itsStop = *currPt;
}
/******************************************************************************
Draw
On entry the pattern is allready set to patXor. This method is called
alternately for drawing and erasing. Default draws a rect from a to b;
*******************************************************************************/
void
CGraphTask::Draw(Point a, Point b) {
Rect r;
Pt2Rect(a, b, &r);
FrameRect(&r);
}
/******************************************************************************
GetStop
Return the last position.
*******************************************************************************/
void
CGraphTask::GetStop(Point *pt) {
*pt = itsStop;
}
/******************************************************************************
GetRect
Return the rectangle that was spanned with the mouse move.
*******************************************************************************/
void
CGraphTask::GetRect(Rect *result) {
Pt2Rect(itsStart, itsStop, result);
}